`
<div class="Textlist">
<ul class="list">
<li>事件1</li>
<li>事件2</li>
<li>事件3</li>
<li>事件4</li>
</ul>
</div>
</div>
<script>
const SwitchBtn = document.querySelector(".SwitchBtn");
console.log(SwitchBtn);
const OpenList = document.querySelector(".list");
console.log(OpenList);
const TextList = document.querySelector(".Textlist");
console.log(TextList);
SwitchBtn.addEventListener("click", () => {
OpenList.classList.toggle("show"); // 使用toggle 做切換Class
});
</script>